package org.mc.sbd.redis.application;

import cn.hutool.core.util.IdUtil;
import org.mc.sbd.redis.infrastructure.dao.RedisTokenCacheDao;
import org.mc.sbd.redis.infrastructure.po.RedisToken;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class RedisTokenApplicationService {
    @Resource
    private RedisTokenCacheDao tokenCacheService;

    public RedisToken create(String value) {
        RedisToken newToken = new RedisToken(IdUtil.getSnowflakeNextId(), value);
        tokenCacheService.save(newToken);

        return newToken;
    }

    public void delete(Long id) {
        tokenCacheService.deleteById(id);
    }
}
